<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ref</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../index.html" title="Chapter 1. Boost.Core">
<link rel="up" href="../index.html" title="Chapter 1. Boost.Core">
<link rel="prev" href="quick_exit.html" title="quick_exit">
<link rel="next" href="../boost/is_reference_wrapper.html" title="Struct template is_reference_wrapper">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="quick_exit.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../boost/is_reference_wrapper.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="core.ref"></a><a class="link" href="ref.html" title="ref">ref</a>
</h2></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="ref.html#core.ref.introduction">Introduction</a></span></dt>
<dt><span class="section"><a href="ref.html#core.reference">Reference</a></span></dt>
<dt><span class="section"><a href="ref.html#core.ref.acknowledgments">Acknowledgments</a></span></dt>
</dl></div>
<div class="simplesect">
<div class="titlepage"><div><div><h3 class="title">
<a name="idm10326"></a>Authors</h3></div></div></div>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
          Jaakko Järvi
        </li>
<li class="listitem">
          Peter Dimov
        </li>
<li class="listitem">
          Douglas Gregor
        </li>
<li class="listitem">
          Dave Abrahams
        </li>
<li class="listitem">
          Frank Mori Hess
        </li>
<li class="listitem">
          Ronald Garcia
        </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="core.ref.introduction"></a><a class="link" href="ref.html#core.ref.introduction" title="Introduction">Introduction</a>
</h3></div></div></div>
<p>
        The Ref library is a small library that is useful for passing references
        to function templates (algorithms) that would usually take copies of their
        arguments. It defines the class template <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">reference_wrapper</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code>,
        two functions <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">ref</span></code> and <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">cref</span></code>
        that return instances of <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">reference_wrapper</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code>,
        a function <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">unwrap_ref</span></code> that unwraps a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">reference_wrapper</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> or
        returns a reference to any other type of object, and the two traits classes
        <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">is_reference_wrapper</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> and
        <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">unwrap_reference</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code>.
      </p>
<p>
        The purpose of <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">reference_wrapper</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> is
        to contain a reference to an object of type <code class="computeroutput"><span class="identifier">T</span></code>.
        It is primarily used to "feed" references to function templates
        (algorithms) that take their parameter by value.
      </p>
<p>
        To support this usage, <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">reference_wrapper</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code>
        provides an implicit conversion to <code class="computeroutput"><span class="identifier">T</span><span class="special">&amp;</span></code>. This usually allows the function templates
        to work on references unmodified.
      </p>
<p>
        <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">reference_wrapper</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> is
        both CopyConstructible and Assignable (ordinary references are not Assignable).
      </p>
<p>
        The <code class="computeroutput"><span class="identifier">expression</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">ref</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code> returns
        a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">reference_wrapper</span><span class="special">&lt;</span><span class="identifier">X</span><span class="special">&gt;(</span><span class="identifier">x</span><span class="special">)</span></code> where
        <code class="computeroutput"><span class="identifier">X</span></code> is the type of <code class="computeroutput"><span class="identifier">x</span></code>. Similarly, <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">cref</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code>
        returns a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">reference_wrapper</span><span class="special">&lt;</span><span class="identifier">X</span> <span class="keyword">const</span><span class="special">&gt;(</span><span class="identifier">x</span><span class="special">)</span></code>.
      </p>
<p>
        The expression <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">unwrap_ref</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code> returns
        a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">unwrap_reference</span><span class="special">&lt;</span><span class="identifier">X</span><span class="special">&gt;::</span><span class="identifier">type</span><span class="special">&amp;</span></code>
        where <code class="computeroutput"><span class="identifier">X</span></code> is the type of <code class="computeroutput"><span class="identifier">x</span></code>.
      </p>
<p>
        The expression <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">is_reference_wrapper</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">value</span></code> is <code class="computeroutput"><span class="keyword">true</span></code>
        if <code class="computeroutput"><span class="identifier">T</span></code> is a <code class="computeroutput"><span class="identifier">reference_wrapper</span></code>,
        and <code class="computeroutput"><span class="keyword">false</span></code> otherwise.
      </p>
<p>
        The type-expression <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">unwrap_reference</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">type</span></code> is <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">type</span></code>
        if <code class="computeroutput"><span class="identifier">T</span></code> is a <code class="computeroutput"><span class="identifier">reference_wrapper</span></code>,
        <code class="computeroutput"><span class="identifier">T</span></code> otherwise.
      </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="core.reference"></a>Reference</h3></div></div></div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="header.boost.core.ref_hpp"></a>Header &lt;<a href="../../../../../boost/core/ref.hpp" target="_top">boost/core/ref.hpp</a>&gt;</h4></div></div></div>
<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">&gt;</span> <span class="keyword">struct</span> <a class="link" href="../boost/is_reference_wrapper.html" title="Struct template is_reference_wrapper">is_reference_wrapper</a><span class="special">;</span>

  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">&gt;</span> <span class="keyword">class</span> <a class="link" href="../boost/reference_wrapper.html" title="Class template reference_wrapper">reference_wrapper</a><span class="special">;</span>

  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">&gt;</span> <span class="keyword">struct</span> <a class="link" href="../boost/unwrap_reference.html" title="Struct template unwrap_reference">unwrap_reference</a><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">&gt;</span> <a class="link" href="../boost/reference_wrapper.html" title="Class template reference_wrapper">reference_wrapper</a><span class="special">&lt;</span> <span class="identifier">T</span> <span class="special">&gt;</span> <span class="keyword">const</span> <a class="link" href="../boost/ref_idm10632.html" title="Function template ref"><span class="identifier">ref</span></a><span class="special">(</span><span class="identifier">T</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">&gt;</span> <a class="link" href="../boost/reference_wrapper.html" title="Class template reference_wrapper">reference_wrapper</a><span class="special">&lt;</span> <span class="identifier">T</span> <span class="keyword">const</span>  <span class="special">&gt;</span> <span class="keyword">const</span> <a class="link" href="../boost/cref_idm10646.html" title="Function template cref"><span class="identifier">cref</span></a><span class="special">(</span><span class="identifier">T</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">&gt;</span> <span class="keyword">void</span> <a class="link" href="../boost/ref_idm10660.html" title="Function template ref"><span class="identifier">ref</span></a><span class="special">(</span><span class="identifier">T</span> <span class="keyword">const</span> <span class="special">&amp;&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">&gt;</span> <span class="keyword">void</span> <a class="link" href="../boost/cref_idm10669.html" title="Function template cref"><span class="identifier">cref</span></a><span class="special">(</span><span class="identifier">T</span> <span class="keyword">const</span> <span class="special">&amp;&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">&gt;</span> <a class="link" href="../boost/unwrap_reference.html" title="Struct template unwrap_reference">unwrap_reference</a><span class="special">&lt;</span> <span class="identifier">T</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">type</span> <span class="special">&amp;</span> <a class="link" href="../boost/unwrap_ref.html" title="Function template unwrap_ref"><span class="identifier">unwrap_ref</span></a><span class="special">(</span><span class="identifier">T</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
<span class="special">}</span></pre>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="core.ref.acknowledgments"></a><a class="link" href="ref.html#core.ref.acknowledgments" title="Acknowledgments">Acknowledgments</a>
</h3></div></div></div>
<p>
        <code class="computeroutput"><span class="identifier">ref</span></code> and <code class="computeroutput"><span class="identifier">cref</span></code>
        were originally part of the Tuple library by Jaakko Järvi. They were
        "promoted to <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span></code>
        status" by Peter Dimov because they are generally useful. Douglas Gregor
        and Dave Abrahams contributed <code class="computeroutput"><span class="identifier">is_reference_wrapper</span></code>
        and <code class="computeroutput"><span class="identifier">unwrap_reference</span></code>. Frank
        Mori Hess and Ronald Garcia contributed <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">unwrap_ref</span></code>.
      </p>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2014 Peter Dimov<br>Copyright © 2014 Glen Fernandes<br>Copyright © 2014 Andrey Semashev<p>
        Distributed under the <a href="http://boost.org/LICENSE_1_0.txt" target="_top">Boost
        Software License, Version 1.0</a>.
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="quick_exit.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../boost/is_reference_wrapper.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
